﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Web.Routing;

namespace Bookmark.Net
{
    public class GlobalApplication : System.Web.HttpApplication
    {
        public static void RegisterRoutes(RouteCollection routes)
        {
            // Note: Change the URL to "{controller}.mvc/{action}/{id}" to enable
            //       automatic support on IIS6 and IIS7 classic mode

            //// Note must specify default values below for optional parameters
            //routes.Add(new Route("rss/{userName}/{tagName}", new MvcRouteHandler())
            //{
            //    Defaults = new RouteValueDictionary(new { controller = "Rss", action = "List", userName = "all", tagName = "" })
            //});
            // Note must specify default values below for optional parameters

    //*** think something is wrong with this 
            //routes.Add(new Route("item/create/{*therest}", new MvcRouteHandler())
            //{
            //    Defaults = new RouteValueDictionary(new { controller = "Item", action = "Create"})
            //});

            // Note must specify default values below for optional parameters
            routes.Add(new Route("item/new/{url}/{title}", new MvcRouteHandler())
            {
                Defaults = new RouteValueDictionary(new { controller = "Item", action = "New", url = "", title = "" })
            });

            // Note must specify default values below for optional parameters
            routes.Add(new Route("item/{action}", new MvcRouteHandler())
            {
                Defaults = new RouteValueDictionary(new { controller = "Item", action = "List", userName = "all", tagName = "" })
            });

            // Note must specify default values below for optional parameters
            routes.Add(new Route("{userName}/{tagName}", new MvcRouteHandler())
            {
                Defaults = new RouteValueDictionary(new { controller = "Item", action = "List", userName = "all", tagName = "" })
            });


            routes.Add(new Route("{controller}/{action}/{id}", new MvcRouteHandler())
            {
                Defaults = new RouteValueDictionary(new { action = "List", id = "" }),
            });

            routes.Add(new Route("Default.aspx", new MvcRouteHandler())
            {
                Defaults = new RouteValueDictionary(new { controller = "Item", action = "List", userName = "all", tagName = "" }),
            });
        }

        protected void Application_Start(object sender, EventArgs e)
        {
            RegisterRoutes(RouteTable.Routes);
        }
    }
}